<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>签到</title>
    <link rel="stylesheet" href="/css/bootstrap3/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/style.css">

    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/travelContent.css"/>

    <script src="js/jquery-1.10.2.min.js"></script>
    <script src="js/calendar.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog/dialog.css">

    <script src="/js/plugins/dialog/dialog.min.js"></script>
    <script src="/js/common.js"></script>



</head>
<body>
<div class="search-head" style="background: #8889c6">
    <div class="row nav-search">
        <div class="col">
            <a href="javascript:history.go(-1);">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col">
        </div>
    </div>
</div>



<div class="container">
    <div class="row">
        <div class="col-xs-12 clearPadding">

            <div class=""><img src="images/qdBanner.jpg" class="img-responsive"></div>

            <div class="calendar">
                <div class="calenbox">
                    <div id="calendar"></div>
                </div>
                <div class="text-center">
                    <button class="btn btn-qiandao" onClick="signIn()">马上签到</button>
                </div>
            </div>
            <div class="padding10">
                <div class="font16 pb10 borderb"><strong>连续签到礼包</strong></div>
                <div class="libaolist">
                    <div class="clearfix borderb ptb10">
                        <div class="col-xs-9 clearPadding">
                            <div class="media">
                                <a class="media-left pt3" href="javascript:void(0);">
                                    <img src="images/dou.png" style="width:30px;height:30px;">
                                </a>
                                <div class="media-body">
                                    <div class="">3天礼包（某巨星演唱会门票一张）</div>
                                    <div class="text-muted font12">连续签到3天即可领取</div>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-3 clearPadding text-right pt2">
                            <button class="btn btn-lingqu" id="day3">领取</button>
                        </div>
                    </div>

                    <div class="clearfix borderb ptb10">
                        <div class="col-xs-9 clearPadding">
                            <div class="media">
                                <a class="media-left pt3" href="javascript:void(0);">
                                    <img src="images/dou.png" style="width:30px;height:30px;">
                                </a>
                                <div class="media-body">
                                    <div class="">7天礼包（某巨星演唱会门票一百张）</div>
                                    <div class="text-muted font12">连续签到7天即可领取</div>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-3 clearPadding text-right pt2">
                            <button class="btn btn-lingqu" id="day7">领取</button>
                        </div>
                    </div>

                    <div class="clearfix borderb ptb10">
                        <div class="col-xs-9 clearPadding">
                            <div class="media">
                                <a class="media-left pt3" href="javascript:void(0);">
                                    <img src="images/dou.png" style="width:30px;height:30px;">
                                </a>
                                <div class="media-body">
                                    <div class="">15天礼包（和某巨星共度晚餐资格）</div>
                                    <div class="text-muted font12">连续签到15天即可领取</div>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-3 clearPadding text-right pt2">
                            <button class="btn btn-lingqu" id="day15">领取</button>
                        </div>
                    </div>


                </div>
            </div>
        </div>
    </div>
</div>
<div class="maskbox"></div>
<div class="qdbox">
    <div class="text-center text-green font18"><strong>签到成功！</strong></div>

    <div class="text-center pt10">您已经连续签到&nbsp;<span class="text-green"></span>&nbsp;天,每次签到积分+50</div>
    <!--<div class="text-center ptb15"><img src="images/gift.png" style="width:125px;margin-left:20px;"></div>
    <div class="text-center"><button class="btn btn-lottery">去抽奖</button></div>-->
</div>



<script>
    function signIn() {
        //签到
        $.post("/signs/saveOrUpdate", {userId: id}, function (data) {
            if (data.message) {
                $.alert(data.message)
            }
        })
        setTimeout(function () {

            //回显签到天数
            $.get("/signs/days", {userId: id}, function (data) {
                //console.log(data);
                $(".qdbox span").html(data.days + 1)
            })
        }, 200)


        $(".maskbox").fadeIn();
        $(".qdbox").fadeIn();
        $(".maskbox").height($(document).height());


    }


    $(".maskbox").click(function () {
        $(".maskbox").fadeOut();
        $(".qdbox").fadeOut()
        location.reload()
    });
    var id = getUser().id;
    $(function () {
        //回显连续签到的状态
        $.get("/continuitysign",{day:3},function (data) {
            if(data.state==1){
                $("#day3").attr("disabled", true)
                $("#day3").removeClass("btn-lingqu")
                $("#day3").addClass("btn-disable")
                $("#day3").html("已领取")

            }
        })

        $.get("/continuitysign",{day:7},function (data) {
            if(data.state==1){
                $("#day7").attr("disabled", true)
                $("#day7").removeClass("btn-lingqu")
                $("#day7").addClass("btn-disable")
                $("#day7").html("已领取")
            }
        })

        $.get("/continuitysign",{day:15},function (data) {
            if(data.state==15){
                $("#day15").attr("disabled", true)
                $("#day15").removeClass("btn-lingqu")
                $("#day15").addClass("btn-disable")
                $("#day15").html("已领取")
            }
        })







        //ajax获取日历json数据
        $.get("/signs", {userId: id}, function (data) {

            //var signList=[{"signDay":"9"},{"signDay":"11"},{"signDay":"12"},{"signDay":"13"}];
            var signList = data;
            calUtil.init(signList);

        })


        $("#day3").click(function () {
            $.get("/signs/days", {userId: id}, function (data) {
                if (data.days + 1 >= 3) {

                    /*$("#myModala").modal("show")*/

                    $("#day3").attr("disabled", true)
                    $("#day3").removeClass("btn-lingqu")
                    $("#day3").addClass("btn-disable")
                    $("#day3").html("已领取")



                    $(document).dialog({

                        titleText: '温馨提示',
                        content: '恭喜您获得逍遥老师个人演唱会门票一张',
                    });

                    var state;
                    $.post("/continuitysign",{day:data.days,state:1},function (data) {

                    })

                }
                else {

                    $(document).dialog({

                        titleText: '温馨提示',
                        content: '签到天数不足',
                    });
                }
            })
        })


        $("#day7").click(function () {
            $.get("/signs/days", {userId: id}, function (data) {
                if (data.days + 1 >= 7) {

                    $("#day7").attr("disabled", true)
                    $("#day7").removeClass("btn-lingqu")
                    $("#day7").addClass("btn-disable")
                    $("#day7").html("已领取")


                    $(document).dialog({

                        titleText: '温馨提示',
                        content: '恭喜您获得逍遥老师个人演唱会门票1百张',
                    });
                }


                else {

                    $(document).dialog({

                        titleText: '温馨提示',
                        content: '签到天数不足',
                    });
                }
            })
        })
        $("#day15").click(function () {
            $.get("/signs/days", {userId: id}, function (data) {
                if (data.days + 1 >= 15) {

                    $("#day15").attr("disabled", true)
                    $("#day15").removeClass("btn-lingqu")
                    $("#day15").addClass("btn-disable")
                    $("#day15").html("已领取")

                    $(document).dialog({

                        titleText: '温馨提示',
                        content: '恭喜您获得和逍遥老师共度晚餐的机会,请马上联系10010',
                    });


                }
                else {

                    $(document).dialog({
                        titleText: '温馨提示',
                        content: '签到天数不足',
                    });
                }
            })
        })


    });





</script>

</body>
</html>
